/**
 * Created by 768138386@qq.com on 2017/7/19.
 */
angular.module('starter.services', [])
    .service('storageService', storageService);

function storageService($window) {

    return {
        set: set,
        get: get,
        setObject: setObject,
        getObject: getObject
    };

    function set(key, value) {
        $window.localStorage[key] = value;
    }

    function get(key) {
        return $window.localStorage[key] || '';
    }

    function setObject(key, value) {
        $window.localStorage[key] = JSON.stringify(value);
    }

    function getObject(key) {
        return JSON.parse($window.localStorage[key] || '{}');
    }

}